Skip to content

feat(tools): add Safety plan generator as a Tools-page tool (not a mode)#1068

Merged
BigSimmo merged 10 commits into
mainfrom
claude/safety-planning-tools-page-tsq4vs
Jul 22, 2026
Merged

feat(tools): add Safety plan generator as a Tools-page tool (not a mode)#1068
BigSimmo merged 10 commits into
mainfrom
claude/safety-planning-tools-page-tsq4vs

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Promotes the Patient Safety Plan generator (Stanley-Brown six steps, live patient copy) from a /mockups prototype to a production Tools-page tool, reachable at /safety-planwithout registering it as an app mode (src/lib/app-modes.ts is intentionally untouched: it gets no sidebar/MODE-dropdown/mode-home entry).
  • Renames patient-safety-plan-mockup.tsxpatient-safety-plan.tsx (export PatientSafetyPlan). Now that it is a production file (no longer -mockup-exempt from the design-system/lint gates), tokenises the two 44px tap classes (min-h-tap, size-tap) and adds aria-hidden to a decorative icon.
  • Adds the route src/app/safety-plan/page.tsx (thin server component rendering <PatientSafetyPlan />).
  • Retires the redundant /mockups/patient-safety-plan route and its mockups-layout-client special-case.
  • Adds a safety-plan Tools catalog tile (href: /safety-plan, care area, safety-first), its launcher icon (ClipboardList), and a reachability fixture so the route passes route-reachability + site-map gates. Distinct from the existing risk-safety tool, which is a safety-check query, not a plan builder.
  • Regenerates docs/site-map.md and indexes the route in docs/codebase-index.md.

RAG impact: no retrieval behaviour change — self-contained UI tool + Tools tile; no src/lib/rag/**, clinical-search, retrieval, ranking, or eval surfaces touched.

Verification

  • npm run verify:cheap — green (lint, typecheck, route-reachability, tools-catalog, site-map, design-system contract, docs:check-index, sitemap:check, knip).
  • npm run verify:pr-local — unit suite 3164 passed. The sole failure, tests/pdf-extraction-budget.test.ts ("terminates the Python child tree when the total deadline expires"), is pre-existing and environment-limited: it fails identically on the base tree with this branch's changes stashed, and touches no code in this diff. The gate's conditional production build sits behind that pre-existing failure.
  • UI verification not run: the sandbox browser gate (verify:ui) was not run locally; the change adds a self-contained page plus a literal Tools tile link, both covered by the route-reachability and site-map unit tests. Recommend verify:ui in review/CI.
  • npm run verify:release: not applicable (no release/handoff claim).
  • eval:retrieval:quality / eval:rag / eval:quality: not applicable — no retrieval, ranking, selection, chunking, or answer-generation behaviour changed.

Risk and rollout

  • Risk: Low. Additive UI — a new self-contained /safety-plan page and a Tools launcher tile. No auth, data, Supabase, ingestion, retrieval, or provider paths touched; app-modes.ts unchanged.
  • Rollback: revert the single commit — removes the route + tile and restores the /mockups/patient-safety-plan prototype.
  • Provider or production effects: None.

Clinical Governance Preflight

The tool produces clinical output (a safety-plan document), so completing this section:

  • Source-backed claims still require linked source verification before clinical use — N/A: the tool is a client-side builder with no source-backed claims/retrieval; the plan footer states it is "not a substitute for clinical risk assessment."
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval — the patient name/initials + entries are ephemeral client-side state only; nothing is persisted, uploaded, or transmitted (copy-to-clipboard / browser print only).
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy) — untouched.
  • Service-role keys and private document access remain server-only — untouched.
  • Demo/synthetic content remains clearly separated from real clinical sources — the seeded example entries are illustrative and labelled in-UI ("Sample content shown — edit every field with your patient").
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative — untouched.
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed — this is a documentation/builder aid (clinician-authored plan), not automated recommendation generation; no new decision-support inference.

Notes

  • Follow-up (not in this PR): the page currently ships with the prototype's pre-filled Stanley-Brown sample content (in-UI labelled as sample). A real clinical rollout may prefer empty fields by default — flagged for a product decision.
  • 🤖 Generated with Claude Code

Generated by Claude Code

Summary by CodeRabbit

  • New Features
    • Added a clinician-facing Safety Plan tool with a dedicated /safety-plan page, including launcher/catalog presence and the correct tool icon.
    • Updated the Safety Plan experience to start empty with a Load example option and improved clinician guidance.
    • Enhanced print/handover output so the printable patient copy is shown and non-print UI is hidden.
  • Documentation
    • Updated the codebase index and site map to include /safety-plan and removed the previous mockup route entry.
  • Bug Fixes
    • Updated UI tool directory counts and filtering expectations to reflect the added Safety Plan tool.

Promote the patient safety-plan generator from a /mockups prototype to a
production Tools-page tool, reachable at /safety-plan without registering
it as an app mode.

- Rename patient-safety-plan-mockup.tsx -> patient-safety-plan.tsx and
  export PatientSafetyPlan; tokenise the two 44px tap classes (min-h-tap,
  size-tap) and add aria-hidden to a decorative icon now that the file is
  production (no longer mockup-exempt from the design-system/lint gates).
- Add the /safety-plan route (src/app/safety-plan/page.tsx).
- Retire the redundant /mockups/patient-safety-plan route and its
  mockups-layout-client special-case.
- Add a "safety-plan" Tools catalog tile (href /safety-plan, care area,
  safety-first), its launcher icon, and a reachability fixture.
- Regenerate docs/site-map.md and index the route in docs/codebase-index.md.

app-modes.ts is intentionally untouched: this is a tool, not a mode.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Jurbrad9ZeWo45EQpxBzR
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 87b29886-26f5-4eb1-aaca-668305cd4707

📥 Commits

Reviewing files that changed from the base of the PR and between c97448e and 36d6e8c.

📒 Files selected for processing (1)
  • src/components/patient-safety-plan.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/patient-safety-plan.tsx

📝 Walkthrough

Walkthrough

Adds the Safety plan tool to catalog and directory data, exposes it at /safety-plan, removes its mockup route, updates shared composer behavior, adds printable patient-copy styling, and documents the new route.

Changes

Safety plan tool

Layer / File(s) Summary
Catalog and directory integration
src/lib/tools-catalog.ts, src/components/tools-page-mockups/tool-fixtures.ts, src/components/applications-launcher-page.tsx, tests/ui-tools-task-directory.spec.ts
Adds the Safety plan catalog and fixture entries, assigns its ClipboardList icon, and updates directory counts and filter expectations.
Product page and component
src/components/patient-safety-plan.tsx, src/app/safety-plan/page.tsx
Renames the rendered component, creates the /safety-plan page with metadata, starts plans empty, adds example/reset actions, and updates accessibility and clinician-facing content.
Printable safety plan output
src/components/patient-safety-plan.tsx, src/app/globals.css
Marks editor and preview controls for print exclusion, identifies the patient-copy panel, and adds print-only patient-copy layout rules.
Route migration and sitemap
src/app/mockups/mockups-layout-client.tsx, docs/site-map.md, scripts/generate-site-map.ts, docs/codebase-index.md
Removes the mockup route, adjusts composer visibility, and adds the new product route to generated and documented sitemap data.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ToolDirectory
  participant SafetyPlanPage
  participant PatientSafetyPlan
  participant PrintStyles
  ToolDirectory->>SafetyPlanPage: provides /safety-plan route
  SafetyPlanPage->>PatientSafetyPlan: renders the safety plan tool
  PatientSafetyPlan->>PrintStyles: supplies printable-copy markers
  PrintStyles->>PatientSafetyPlan: formats the patient-copy document
Loading

Possibly related PRs

Suggested labels: codex

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately captures the main change: promoting the Safety plan generator to a Tools-page tool.
Description check ✅ Passed The description follows the template well, covering summary, verification, risk/rollback, clinical governance, and notes with meaningful detail.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/safety-planning-tools-page-tsq4vs

Comment @coderabbitai help to get the list of available commands.

@supabase

supabase Bot commented Jul 22, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

…an tile

Adding the safety-plan Tools fixture grows the shared mockup tool set from
7 to 8 (Safety plan is a care-area = "Clinical" tool), so the task-directory
mockup's derived counts shift: total 7 -> 8 and the Clinical chip 4 -> 5;
the Admin chip stays 3. Update the Playwright expectations to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Jurbrad9ZeWo45EQpxBzR
@BigSimmo
BigSimmo marked this pull request as ready for review July 22, 2026 04:59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

const printPlan = () => {
if (typeof window !== "undefined") window.print();

P2 Badge Isolate the patient copy before printing

When a desktop user clicks “Print / PDF”, this calls window.print() for the whole page with no safety-plan-specific print mode; the existing global print CSS hides headers/nav/buttons but does not hide #spg-panel-build, and it also hides the preview document header because it is a <header>. The advertised patient-copy export therefore includes builder/editor content and loses the plan title/name/date area instead of printing only the handover copy; add a print-only sheet or scoped no-print/print classes before exposing this as a clinical tool.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/patient-safety-plan.tsx Outdated
Comment thread src/app/safety-plan/page.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/patient-safety-plan.tsx`:
- Around line 40-49: Update the clearAll handler to reset patient context
fields, including patient and planDate, along with the existing plan content
fields. Ensure the cleared state is used consistently by the preview and copied
output, while preserving the current Clear all behavior for the remaining form
data.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 691c4469-0edb-4f35-bb76-6033cce4cf7f

📥 Commits

Reviewing files that changed from the base of the PR and between 3e70a22 and cf2047b.

📒 Files selected for processing (11)
  • docs/codebase-index.md
  • docs/site-map.md
  • scripts/generate-site-map.ts
  • src/app/mockups/mockups-layout-client.tsx
  • src/app/mockups/patient-safety-plan/page.tsx
  • src/app/safety-plan/page.tsx
  • src/components/applications-launcher-page.tsx
  • src/components/patient-safety-plan.tsx
  • src/components/tools-page-mockups/tool-fixtures.ts
  • src/lib/tools-catalog.ts
  • tests/ui-tools-task-directory.spec.ts
💤 Files with no reviewable changes (1)
  • src/app/mockups/patient-safety-plan/page.tsx

Comment thread src/components/patient-safety-plan.tsx
…, clear-all

Resolves the review findings on the promoted /safety-plan tool:

- Start empty (Codex P2): a fresh plan boots blank instead of seeding sample
  content, so placeholder names and non-working example crisis numbers can no
  longer reach a Finalise/Copy/Print handover. A new "Load example" button
  restores the Stanley-Brown sample on demand for demos/training, keeping the
  seed data as an opt-in fixture rather than a default.
- Print isolation (Codex P2): "Print / PDF" (and Cmd+P) now export the patient
  copy only. Builder/editor chrome is marked data-print-hide, the patient-copy
  pane is data-safety-plan-copy, and a scoped @media print block restores the
  document header that the global `header { display:none }` rule would drop.
- main-content landmark (Codex P2): the component root is now
  <main id="main-content" tabIndex={-1}>, so the layout's skip link has a live
  target and assistive tech gets the expected main landmark on /safety-plan.
- Clear all (CodeRabbit): also resets patient name and date so stale patient
  identifiers can't carry into the next plan.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Jurbrad9ZeWo45EQpxBzR

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/patient-safety-plan.tsx`:
- Around line 493-497: Update loadExample to confirm before replacing a
non-empty plan, aborting without changes when the user declines. When confirmed
or no plan content exists, replace the entries and reasons with the seed data,
reset finalised, and also clear the patient and planDate context so sample
content cannot retain real patient identity or date.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5642164f-c3c4-467e-ad51-fd32e1091c2f

📥 Commits

Reviewing files that changed from the base of the PR and between cf2047b and c97448e.

📒 Files selected for processing (2)
  • src/app/globals.css
  • src/components/patient-safety-plan.tsx

Comment thread src/components/patient-safety-plan.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c97448eab1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/patient-safety-plan.tsx
claude and others added 2 commits July 22, 2026 05:28
…ntity

Codex (P2) and CodeRabbit (Major) flagged that the example loader could bridge
sample content into patient output. loadExample now:
- confirms before replacing a non-empty in-progress plan (prevents accidental
  loss of a clinician's work), and
- clears patient name and date, so the Priya/Jordan/Biscuit example content can
  never sit under a real patient's identity in the preview/print copy.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Jurbrad9ZeWo45EQpxBzR
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 22, 2026 05:53
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0a125fb5a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/app/safety-plan/page.tsx
Comment thread src/components/patient-safety-plan.tsx
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69cea27492

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/patient-safety-plan.tsx
@BigSimmo
BigSimmo merged commit 6cdfdcc into main Jul 22, 2026
17 checks passed
@BigSimmo
BigSimmo deleted the claude/safety-planning-tools-page-tsq4vs branch July 22, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants